#include "QuickSort.h"

int main()
{
    vector<int> a, b;
    vector<int>::iterator it;
    double time1, time2;
    int n, m;
    clock_t start, end;

    cout << "请输入向量长度：" << endl;
    cin >> n;
    cout << "请输入向量生成方式：" << endl;
    cin >> m;

    for (int i = 0; i < n; i++)
    {
        if (m == 0)
        {
            a.push_back(i);
            b.push_back(i);
        }
        else if (m == 1)
        {
            a.push_back(n - i);
            b.push_back(n - i);
        }
        else
        {
            int tem = rand() % n;
            a.push_back(tem);
            b.push_back(tem);
        }
    }
    cout << "原向量为： ";

    for (int i = 0; i < n; i++)
    {
        cout << a[i] << " ";
    }

    cout << "\n";

    start = clock();
    sort(a, 0);
    end = clock();
    time1 = end - start;

    cout << "After sort(主元为随机):" << endl;
    for (int i = 0; i < n; i++)
    {
        cout << a[i] << " ";
    }

    start = clock();
    sort(b, 1);
    end = clock();
    time2 = end - start;
    cout << "\n";

    cout << "After sort(主元为中位数):" << endl;
    for (int i = 0; i < n; i++)
    {
        cout << b[i] << " ";
    }
    cout << "\n随机主元用时为：" << time1 << endl;
    cout << "\n中位主元用时为：" << time2 << endl;
}
